package com.jinzhi.api.controller.aunt;

import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.*;
import com.jinzhi.jzweb.service.*;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: mcf
 * @CreateTime: 2024/05/14
 * @Description: 课程 Controller
 */
@Controller
@RequestMapping("/api/auntCourses")
@Api(value = "阿姨端课程中心", tags = "阿姨端课程中心")
public class AuntCoursesController {

    private final JazCoursesService jazCoursesService;

    private final JazUserCommentDescriptionService jazUserCommentDescriptionService;

    private final JazUserCommentService jazUserCommentService;


    public AuntCoursesController(JazCoursesService jazCoursesService,JazUserCommentDescriptionService jazUserCommentDescriptionService,JazUserCommentService jazUserCommentService){
        this.jazCoursesService = jazCoursesService;
        this.jazUserCommentDescriptionService = jazUserCommentDescriptionService;
        this.jazUserCommentService = jazUserCommentService;

    }

    @ApiOperation(value = "阿姨端课程首页列表接口", notes = "阿姨端课程首页列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "size", value = "每页大小", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "curren", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "jazCoursesDO", value = "提交课程表单", required = true, dataType = "Object"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazCoursesDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/auntCoursesList")
    public Result<Page<JazCoursesDO>> auntCoursesList(JazCoursesDO jazCoursesDTO){

        return jazCoursesService.auntCoursesList(jazCoursesDTO);
    }


    @ApiOperation(value = "阿姨端查询课程详情 （包括课程介绍、销量、价格等）", notes = "阿姨端查询课程详情 （包括课程介绍、销量、价格等）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "coursesId", value = "课程id", required = true, dataType = "Long"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazCoursesDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/auntCoursesDetail")
    public Result<JazCoursesDO> auntCoursesDetail(Long coursesId){

        return jazCoursesService.auntCoursesDetail(coursesId);
    }


    @ApiOperation(value = "阿姨端获取课程父章节 并且获取判断是否存在子章节", notes = "阿姨端获取课程父章节 并且获取判断是否存在子章节")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "传上一级的id", required = true, dataType = "Long"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazCoursesChapterDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/auntParentChapter")
    public Result<List<JazCoursesChapterDO>> auntParentChapter(Long id){

        return jazCoursesService.auntParentChapter(id);
    }


    @ApiOperation(value = "月嫂课程浏览量新增", notes = "月嫂课程浏览量新增")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "courseId", value = "课程id", required = true, dataType = "Long"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/addBrowseNum")
    public Result<?> addBrowseNum(Long courseId){

        return jazCoursesService.addBrowseNum(courseId);
    }


    @ApiOperation(value = "我的学习列表", notes = "我的学习列表")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazCoursesDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/learningList")
    public Result<?> learningList() {

        return  jazCoursesService.learningList();
    }


    @ApiOperation(value = "课程评价描述查询", notes = "课程评价描述查询")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazUserCommentDescriptionDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/selCommentDescription")
    public Result<?> selCommentDescription() {

        return  jazUserCommentDescriptionService.selCommentDescription(1);
    }


    @ApiOperation(value = "新增课程评价", notes = "新增课程评价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jazUserCommentDO", value = "jazUserCommentDO", required = true, dataType = "String"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazUserCommentDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping("/addComment")
    public Result<?> addComment(@RequestBody JazUserCommentDO jazUserCommentDO) {

        return  jazUserCommentService.addComment(jazUserCommentDO);
    }


    @ApiOperation(value = "课程评价列表", notes = "课程评价列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页大小", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "commentdObjectid", value = "课程id", required = true, dataType = "Integer"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = JazUserCommentDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping("/commentList")
    public Result<Page<JazUserCommentDO>> list(Integer current,Integer size,Long commentdObjectid){
        return Result.ok(jazUserCommentService.getUserCommentList(1,commentdObjectid,current,size));
    }




}
